<!DOCTYPE html>
<html lang='en'>

<head>
  <meta charset='UTF-8'>
  <meta http-equiv='X-UA-Compatible' content='IE=edge'>
  <meta name='viewport' content='width=device-width, initial-scale=1.0'>
  <title>Document</title>
  <script src='https://cdn.jsdelivr.net/npm/vue/dist/vue.js'></script>
</head>

<body>
  <script type="text/x-template" id="faCpn">
    <div>
      <h2>我是父组件</h2>
      <p>我是父组件的内容</p>
      <ch-cpn />
    </div>
  </script>
  <template id="chCpn">
    <div>
      <h2>我是子组件</h2>
      <p>我是子组件的内容</p>
      </div>
  </template>
  <div id='app'>
    <h2>{{message}}</h2>
    <fa-cpn></fa-cpn>
  </div>
  <script>
    // 2.注册为全局父组件
    Vue.component('fa-cpn', {
      template: `#faCpn`,
      // 注册组件为父组件局部组件
      components: {
        'ch-cpn': {
          template: `#chCpn`
        }
      }
    })

    const app = new Vue({
      el: '#app',
      data: {
        message: 'hello world'
      }
    })
  </script>
</body>

</html>